<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .box {
            width: 200px;
            height: 200px;
            margin: 100px auto;
            background-color: black;
            box-sizing: border-box;
            color: white
        }
        
        .box:hover {
            cursor: crosshair;
        }
        
        .box-enter {
            color: red;
            border: 5px solid red;
            background-color: rgb(145, 143, 143);
        }
    </style>
</head>

<body>
    <div class="box">鼠标移入改变样式，鼠标移出恢复。</div>
    <script>
        var box = document.querySelector('.box');
        box.onmouseenter = function() {
            this.classList.add("box-enter")
        }
        box.onmouseleave = function() {
            this.classList.remove("box-enter")
        }
    </script>
</body>

</html>